package edu.spec.basic.service.impl;

import edu.spec.basic.dao.iface.ICommandDao;
import edu.spec.basic.dao.iface.IRoleCommandDao;
import edu.spec.basic.dao.iface.IRoleDao;
import edu.spec.basic.model.Command;
import edu.spec.basic.service.iface.ICommandService;
import org.springframework.stereotype.Service;

import javax.inject.Inject;
import java.util.List;

@Service
public class CommandService implements ICommandService {

    @Inject
    private ICommandDao commandDao;
	@Inject
	private IRoleDao roleDao;
	@Inject
	private IRoleCommandDao roleCommandDao;


    @Override
    public Command add(Command command) {
        return commandDao.add(command);
    }

    @Override
    public void delete(int id) {
	    roleCommandDao.deleteByCommand(id);
        commandDao.delete(id);
    }

	@Override
	public Command load(int id) {
		return commandDao.load(id);
	}

	@Override
    public List<Command> listAllCommand() {
        return commandDao.listAllCommand();
    }

	@Override
	public List<Command> listCommandByModule(int moduleId) {
		return commandDao.listCommandByModule(moduleId);
	}

	@Override
    public List<Command> listCommandByRoles(List<Integer> roleIds) {
        return commandDao.listCommandByRoles(roleIds);
    }

    @Override
    public List<Command> listCommandByRole(Integer roleId) {
        return commandDao.listCommandByRole(roleId);
    }

    @Override
    public Command update(Command command) {
        return commandDao.update(command);
    }
}
